<?php


namespace App\Http\Controllers\api;
use App\Http\Controllers\BaseController;
use App\Models\Banner;
use App\Models\HomepageDialog;
use Illuminate\Http\Request;

class HomepageDialogController extends BaseController
{

    /**
     * 详情
     * @param Request $request
     * @return mixed
     * @throws \Illuminate\Validation\ValidationException
     */
    public function info(Request $request) {
        $info = HomepageDialog::where('status', 1)->first();
        return $this->success($info);
    }

    public function store(Request $request)
    {
        $this->validate($request, [
            'action' => 'required',
            'id' => 'required'
        ]);
        $input = $request->input();
        $action = $request->input('action');
        $id = $request->input('id');
        $field = 'close_times';
        if ($action == 'click') {
            $field = 'click_times';
        }
        HomepageDialog::where('id', $id)->increment($field);
        return $this->success([]);
    }


}

